<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrganizationsTable extends Migration
{
    /**
     * Run the migrations.
     * 组织表---公司企业
     * @return void
     */
    public function up()
    {
        Schema::create('organizations', function (Blueprint $table) {
            $table->increments('id');
            $table->string('mark')->comment('组织编码');
            $table->string('name')->comment('组织名称');
            $table->integer('parent_id')->unsigned()->comment('上级组织')->default(0);
            $table->string('address')->comment('组织地址')->nullable();
            // $table->string('area_id')->comment('组织区域')->nullable();
            // $table->foreign('area_id')->references('id')->on('carareas');
            // $table->string('principal')->comment('组织负责人')->nullable();
            // $table->string('phone')->comment('负责人电话')->nullable();
            $table->integer('logo')->comment('组织logo')->nullable();
            $table->text('description')->comment('描述信息')->nullable();
            $table->boolean('data_state')->comment('数据状态 0未审核 1已审核')->default(0);
            $table->boolean('disabled_state')->comment('禁用状态 0反禁用-启用 1禁用')->default(0);
            //$table->string('memo_code')->comment('助记码');
            $table->softDeletes();
            $table->timestamps();
            $table->unique(['name','deleted_at']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('organizations');
    }
}
